#include <QApplication>
#include <QQmlApplicationEngine>
#include <QTextCodec>
#include <QByteArray>
#include <QtWidgets/QApplication>
#include <QQuickView>
#include <QtQuickWidgets/QQuickWidget>
#include <QQmlComponent>
#include <QQmlContext>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

#include "sharedata.h"
#include "serialcontroller.h"
#include "lua_wraper.h"
#include "mainwindow.h"
#include <windows.h>

int main(int argc, char *argv[])
{
#ifdef WIN32
    WORD wdVersion = MAKEWORD(2, 2);//定义自己需要的网络库版本，这里是2.2
    WSADATA wdSockMsg;//这是一个结构体
    int nRes = WSAStartup(wdVersion, &wdSockMsg);//打开一个套接字
    if (0 != nRes) {
        switch (nRes) {
            case WSASYSNOTREADY:
                printf("check your library");
            break;
            case WSAVERNOTSUPPORTED:
                printf("need updated");
                break;
            case WSAEINPROGRESS:
                printf("need reboot");
                break;
            case WSAEPROCLIM:
             printf("sdfsdfsa");
             break;
        }
    }
    if (2 != HIBYTE(wdSockMsg.wVersion) || 2 != LOBYTE(wdSockMsg.wVersion)) {
        printf("WSACleanup");
        WSACleanup();
        return 0;
    }
#endif

    AllocConsole();
    freopen("CONOUT$","w",stdout);

    QApplication app(argc, argv);
    QQmlApplicationEngine engine;

    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    printf("hello world");
    MainWindow w;
    w.setWindowTitle("协议调试器");
    w.show();

    return app.exec();
}
